
var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
	clicksToEdit: 2
});


var contextMenu = Ext.create('Ext.menu.Menu', {
	height: 100,
	width: 125,
	items: [{
			text: 'View Invoice',
			icon: 'icons/document-text.png'
		}, {
			text: 'Edit Invoice',
			icon: 'icons/pencil.png'
		}, {
			text: 'Re-Send Invoice',
			icon: 'icons/envelope-label.png'
		}, {
			text: 'Delete Invoice',
			icon: 'icons/minus-circle.png'
	}]
});

var invoicesGrid = Ext.define('AM.view.invoice.invoiceList' ,{
    extend: 'Ext.grid.Panel',
    alias: 'widget.invoiceList',
    width: 600,
    height: 300,
    title: 'Grids --- My Invoice List',
    store: 'Invoices',
    plugins: [rowEditing],
    selType: 'rowmodel',
    initComponent: function() {
        this.columns = [{
        	header: 'Client',
        	dataIndex: 'Client',
        	flex: 1,
        	editor: {
        		allowBlank: false
        	}
        	}, {
        	header: 'Date',
        	dataIndex: 'Date'
        	}, {
        	header: 'Amount',
        	dataIndex: 'Amount',
        	xtype: 'numbercolumn',
        	editor: {
	        	xtype: 'numberfield',
	        	allowBlank: false,
	        	hideTrigger: true,
	        	minValue: 1,
	        	maxValue: 150000
        	}
	    	}, {
        	header: 'Status',
        	dataIndex: 'Status'
        	}
        ];

        this.callParent(arguments);
    }
});

invoicesGrid.on({
		itemcontextmenu: function(view, record, item, index, e){
		e.stopEvent();
		contextMenu.showAt(e.getXY());
	}
});